<?php defined('SYSPATH') or die('No direct script access.');

/**
 * 分享应用功能接口
 */
class Controller_Pc_Api_V2_Share extends Controller_Pc_Api_v2_Base
{

    private $result;

    /**
     * 验证类
     * @var Request_Api_V2_Share
     */
    private $validation;

    /**
     * 服务类
     * @var Service_Api_Share
     */
    private $service;

    //评论api控制器
    public function before()
    {
        parent::before();
        $this->result = array(
            'status' => true,//默认状态为成功
            'msg' => '操作成功',//默认的提示消息
            'data' => array()
        );
        $this->validation = Request_Api_V2_Factory::create('share', $this->request_params);
        $this->service = new Service_Api_Share();

    }
    public function after()
    {
        $this->send_datagrams($this->client_info['id'], $this->result, $this->client_info['secret_key']);
    }

    /**
     * 普通分享接口
     */
    public function action_share_wx_info()
    {
        try {
            $this->validation->share_wx_info()->check();
            $data = $this->service->share_wx_info($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }
    /**
     * 微信分销商分享
     */
    public function action_share_wx_fenxiao_info()
    {
        try {
            $this->validation->share_wx_fenxiao_info()->check();
            $data = $this->service->share_wx_fenxiao_info($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 小程序分享
     */
    public function action_share_mp_info()
    {
        try {
            $data = $this->service->share_mp_info($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }

    }

}
